import request from '@/utils/request'

// 查询商品信息列表
export function listGoods(query) {
  return request({
    url: '/goods/goods/list',
    method: 'post',
    data: query
  })
}

// 查询商品信息详细
export function getGoods(id) {
  return request({
    url: '/goods/goods/' + id,
    method: 'get'
  })
}

// 新增商品信息
export function addGoods(data) {
  return request({
    url: '/goods/goods/add',
    method: 'post',
    data: data
  })
}

// 修改商品信息
export function updateGoods(data) {
  return request({
    url: '/goods/goods/update',
    method: 'post',
    data: data
  })
}

// 删除商品信息
export function delGoods(id) {
  return request({
    url: '/goods/goods/delete/' + id,
    method: 'post'
  })
}

// 查询商品下是否有sku
export function queryGoodsSkuExist(id) {
  return request({
    url: '/goods/goods/skus/' + id,
    method: 'get'
  })
}

export function uploadFile(data) {
  return request({
    url: '/file/upload',
    method: 'post',
    data: data,
    headers: { 'content-type': 'multipart/form-data' }
  })
}

// 停用
export function close(id) {
  return request({
    url: '/goods/goods/close/' + id,
    method: 'post'
  })
}
// 启用
export function restart(id) {
  return request({
    url: '/goods/goods/restart/' + id,
    method: 'post'
  })
}
